-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK-1931] Add support for canActivateChild and canLoad in AuthGuard #45
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stevehobbsdev
added
CH: Added
PR is adding feature or functionality
dependencies
One or more dependencies are being bumped
enhancement
An enhancement or improvement to the SDK that could not be otherwise categorized as a new feature
review:medium
Medium review
labels
Sep 8, 2020
stevehobbsdev
commented
Sep 8, 2020
lbalmaceda
suggested changes
Sep 9, 2020
projects/playground/src/app/child-route/nested-child-route.component.ts
Outdated
Show resolved
Hide resolved
@Component({ | ||
selector: 'app-lazy-module', | ||
templateUrl: './lazy-module.component.html', | ||
styleUrls: ['./lazy-module.component.css'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the others inline the template and remove the styles (empty array). This one looks like the auto-generated one. Let's keep one style on all of them, and remove unnecessary files (e.g. styles, template, etc)
projects/playground/src/app/lazy-module/lazy-module.component.ts
Outdated
Show resolved
Hide resolved
projects/playground/src/app/lazy-module/lazy-module.component.spec.ts
Outdated
Show resolved
Hide resolved
stevehobbsdev
force-pushed
the
add/auth-guards
branch
from
September 10, 2020 13:36
4d73c7d
to
7c945a3
Compare
lbalmaceda
approved these changes
Sep 11, 2020
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CH: Added
PR is adding feature or functionality
dependencies
One or more dependencies are being bumped
enhancement
An enhancement or improvement to the SDK that could not be otherwise categorized as a new feature
review:medium
Medium review
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for two other Guard interfaces: CanActivateChild and
CanLoad
determine whether any of those child routes can be accessed
should be loaded or not
The playground has been updated with some new links that demonstrate these
scenarios. For
canLoad
, observe the network trace while authenticated tosee that the JS assets for that module are only loaded when the route is
accessed. When unauthenticated, clicking the link does nothing as the module
should not be loaded. In the real world,
canActivate
may also be used onthis route to auto-login if it is accessed, but I wanted to test only the
loading part here.
Additionally,
canActivateChild
necessitates two new components and routesbeing added to the playground:
/child
, and/child/nested
. The former shouldbe accessible anonymously, while the latter (a child route) requires a login
and will auto-login when accessed.
Unit tests available for the new AuthGuard functionality and E2E tests have
been defined to cover the behaviour on the playground.
Note: This PR also updates SPA SDK to 1.12.0. More dependency updates coming in a future PR.